package com.gzc.just.play.last.war.centralserver.inventory.repository;

import com.gzc.just.play.last.war.centralserver.inventory.model.Item;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface ItemRepository extends JpaRepository<Item, Long> {
    
    Optional<Item> findByName(String name);
    
    List<Item> findByType(String type);
    
    @Query("SELECT i FROM Item i WHERE i.stackable = true")
    List<Item> findStackableItems();
    
    @Query("SELECT i FROM Item i WHERE i.usable = true")
    List<Item> findUsableItems();
}
